<template>
<section>
  <el-descriptions  title="基本信息" :column="2">
    <template slot="extra"  v-if="canModify">
      <el-button type="primary" size="small" @click.native="editBase">编 辑</el-button>
    </template>
       <el-descriptions-item label="采购单">{{ orderInfo.purchaseNo||'--' }}</el-descriptions-item>
       <el-descriptions-item label="供应商">
         <el-tag size="small">{{ orderInfo.supplierName||'--' }}</el-tag>
         </el-descriptions-item>
       <el-descriptions-item label="订单金额">{{ orderInfo.purchaseAmount||'--' }}</el-descriptions-item>
       <el-descriptions-item label="实际订单金额">{{ orderInfo.purchaseActualAmount||'--' }}</el-descriptions-item>
       <el-descriptions-item label="采购日期">{{ orderInfo.purchaseDate | FormatDate('yyyy-MM-dd') ||'--'}}</el-descriptions-item>
       <el-descriptions-item label="完成日期">{{ orderInfo.purchaseCompletedDate | FormatDate('yyyy-MM-dd')||'--' }}</el-descriptions-item>
       <el-descriptions-item label="负责人">{{ orderInfo.chargePersonName||'--' }}</el-descriptions-item>
       <el-descriptions-item label="备注">{{ orderInfo.remark ||'--'}}</el-descriptions-item>
  </el-descriptions>
  <el-descriptions  title="系统信息" :column="2" size="small">
       <el-descriptions-item label="创建人">{{ orderInfo.creatorName||'--' }}</el-descriptions-item>
       <el-descriptions-item label="创建时间">{{ orderInfo.createTime || '--' }}</el-descriptions-item>
       <el-descriptions-item label="最后更新人">{{ orderInfo.updaterName||'--' }}</el-descriptions-item>
       <el-descriptions-item label="更新时间">{{ orderInfo.updateTime ||'--' }}</el-descriptions-item>
  </el-descriptions>
   <Order-base v-if="visibleBase" :visible.sync="visibleBase" :param="orderInfo" @saveAfter="editAfter"/>
</section>
</template>

<script>
import Mixins from '../mixins'
import OrderBase from './edit/order_base'
export default {
  components: {OrderBase},
  mixins: [Mixins],
  props: {
    canModify: { type: Boolean, default: false },
    param: {type: String, default: null},
    orderInfoData: {type: Object,
      default: () => {
        return {}
      }}
  },
  data () {
    return {
      purchaseNo: this.param,
      orderInfo: {},
      visibleBase: false
    }
  },
  created () {
    this.getPurchaseOrderInfo(this.purchaseNo)
  },
  methods: {
    editBase () {
      this.visibleBase = true
    },

    editAfter (purchaseNo) {
      this.getPurchaseOrderInfo(purchaseNo)
      this.$emit('editAfter')
    },
    getPurchaseOrderInfo (purchaseNo) {
      this.requestOption('getPurchaseOrderInfo', purchaseNo, res => {
        this.orderInfo = res.data || {}
        this.$emit('update:orderInfoData', this.orderInfo)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
